/***************************************************************
 * Name:      minesweeperMain.h
 * Purpose:   Defines Application Frame
 * Author:    li ()
 * Copyright: li ()
 * License:
 **************************************************************/

#ifndef MINESWEEPERMAIN_H
#define MINESWEEPERMAIN_H

//(*Headers(minesweeperFrame)
#include <wx/button.h>
#include <wx/frame.h>
#include <wx/menu.h>
#include <wx/panel.h>
#include <wx/sizer.h>
//*)
#include "Board.h"
#include "LCD.h"
#include <list>

class minesweeperFrame: public wxFrame {
  public:
    minesweeperFrame(wxWindow* parent,wxWindowID id = -1);
    virtual ~minesweeperFrame();

  protected:
    void initMode(int m);
    void resize(int width, int height);
    void initGame();
    void Open(const Point &pt);
    void Mark(const Point &pt);
    void multiOpen(const Point &pt);
    void firstClick(const Point &pt);
    void Blink();
    void fail(const Point &pt);
    void success();

    void after_initMode_();
    void after_initGame_();
    void autoMark_after_click_();
    void autoOpen_after_click_();
    void autoOpen_after_Mark_(const Point &pt);
    void update_chance_();

  private:
    //(*Handlers(minesweeperFrame)
    void OnAbout(wxCommandEvent& event);
    void OnMenu_ModeSelected(wxCommandEvent& event);
    void OnnewGameClick(wxCommandEvent& event);
    void OntilemapLeftDown(wxMouseEvent& event);
    void OntilemapRightDown(wxMouseEvent& event);
    void OnMenu_markSelected(wxCommandEvent& event);
    void OnMenu_openSelected(wxCommandEvent& event);
    void OntilemapMiddleDown(wxMouseEvent& event);
    //*)

    //(*Identifiers(minesweeperFrame)
    static const long ID_PANEL2;
    static const long ID_BUTTON1;
    static const long ID_PANEL3;
    static const long ID_PANEL1;
    static const long ID_MENUITEM_easy;
    static const long ID_MENUITEM_med;
    static const long ID_MENUITEM_hard;
    static const long ID_MENUITEM_mark;
    static const long ID_MENUITEM_open;
    //*)

    //(*Declarations(minesweeperFrame)
    Board* tilemap;
    LCD* mine_lcd;
    LCD* time_lcd;
    wxBoxSizer* BoxSizer1;
    wxBoxSizer* BoxSizer2;
    wxButton* newGame;
    wxMenu* Menu3;
    wxMenuItem* Menu_easy;
    wxMenuItem* Menu_hard;
    wxMenuItem* Menu_mark;
    wxMenuItem* Menu_med;
    wxMenuItem* Menu_open;
    //*)

    enum MODE {EASY,MEDIUM,HARD};
    enum STATE {BEGIN,RUNNING,END} state;
    int mine_num;
    int left_blank;
    int left_mine;
    std::list<Point> q_0;
    std::list<Point> q_posi;
    std::list<Point> q_click;
    wxTimer map_timer;
    wxTimer num_timer;

    void _Open(const Point &pt);
    void _Mark(const Point &pt);

    bool auto_mark;
    bool auto_open;
    int chance;
    int use_chance;
    int coe;

    DECLARE_EVENT_TABLE()
};

#endif // MINESWEEPERMAIN_H
